/// @file
/// @author Chelsey Batchelor <vadedeyes@gmail.com>
/// @author Abraham Escamilla <abraham.escamilla@live.com>
/// @author Curtis Hollibaugh <curtis.hollibaugh@gmail.com>
/// @copyright Copyright 2014 Chelsey Batchelor <vadedeyes@gmail.com>
/// @copyright Copyright 2014 Abraham Escamilla <abraham.escamilla@live.com>
/// @copyright Copyright 2014 Curtis Hollibaugh <curtis.hollibaugh@gmail.com>
/// Contains the declaration of the Gtk class.

#pragma once

#include <gtk/gtk.h>
#include <mutex>
#include <string>

/// Wraps access to GTK+ to make it thread safe
/// This is a static class. It cannot be instantiated.
class Gtk {
	private:
		static std::mutex gtkMutex; ///< Mutex to force serial access to GTK+.
		
	public:
		/// Constructor.
		/// DELETED.
		Gtk() = delete;
		
		/// Destructor.
		/// DELETED.
		~Gtk() = delete;
		
		/// Move constructor.
		/// DELETED.
		Gtk(Gtk&& rhs) = delete;
		
		/// Copy constructor.
		/// DELETED.
		Gtk(const Gtk& rhs) = delete;
		
		/// Move assignment operator.
		/// DELETED.
		Gtk& operator=(Gtk&& rhs) = delete;
		
		/// Copy assignment operator.
		/// DELETED.
		Gtk& operator=(const Gtk& rhs) = delete;
		
		/// Creates a new GtkStatusIcon with no icon.
		/// @return GObject pointer to the new GtkStatusIcon.
		static GtkStatusIcon* CreateStatusIcon();
		
		/// Creates a new GtkStatusIcon with the given image as an icon.
		/// @param [in] filename Filename of the image to use as on icon.
		/// @return GObject pointer to the new GtkStatusIcon.
		static GtkStatusIcon* CreateStatusIcon(const std::string& filename);
		
		/// Destroys the give GtkStatusIcon.
		/// @param [in] statusIcon GtkStatusIcon to destroy.
		static void DestroyStatusIcon(GtkStatusIcon* statusIcon);
		
		/// Gets whether or not the given GtkStatusIcon is visible.
		/// @param [in] statusIcon GtkStatus icon to check the visibility of.
		/// @return true if statusIcon is visible; false if not.
		static bool GetIsVisible(GtkStatusIcon* statusIcon);
		
		/// Initializes the GTK+ framework.
		/// This only needs to be called once.
		static void Init();
		
		/// Performs one iteration of the main GTK+ event loop.
		/// @param [in] blocking Whether or not to block execution until event
		/// loop processes an event.
		static void MainIterationDo(bool blocking = false);
		
		/// Sets the visibility of the given GtkStatusIcon.
		/// @param [in] statusIcon GtkStatusIcon to set the visibility of.
		/// @param [in] visible    Whether or not statusIcon should be visible.
		static void SetIsVisible(GtkStatusIcon* statusIcon, bool visible);
};
